﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using Microtalk.Models;

namespace Microtalk.Data
{
    
    public class SayDemoDbInitilizer:DropCreateDatabaseAlways<MicrotalkContext>
    {
        //创建一个派生类重写Seed方法 可以为程序创建一些初始化数据
        protected override void Seed(MicrotalkContext db)
        {

            db.Users.Add(new Models.Users
            {
                UserName = "青柠",
                PassWord = "123",
                CreateAt = DateTime.Now,
                UpdateAt = DateTime.Now,
                Version = 0
            });

            

            db.Users.Add(new Models.Users
            {
                UserName = "小鹿",
                PassWord = "123",
                CreateAt = DateTime.Now,
                UpdateAt = DateTime.Now,
                Version = 0
            });


            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId=1,
                    Content="MVC的实现微说说",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                },
                new Messages
                {
                    FromUserId=1,
                    Content="什么时候去见你耳机的的那个人",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                },
                new Messages
                {
                    FromUserId=2,
                    Content="JayChou",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                },
            });

            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    MsgId=1,
                    FromUserId=1,
                    Content="模型视图控制器",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                },
                new Comments
                {
                    FromUserId=1,
                    MsgId=1,
                    Content="学!",
                    CreateAt=DateTime.Now,
                    UpdateAt=DateTime.Now,
                    Version=0
                }
            });

            db.SaveChanges();

            base.Seed(db);
        }


    }
}